<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>注册</title>
<script src="http://localhost:8080/CourseSupport/js/jquery-1.11.3.min.js" ></script>
</head>
<body>
<br><br>
<center>注册用户</center><br>
<center>
<form action="user/register" method="post">
	工号:<input name="userCode" id="userCode" type="text" value="2014303326" /><br>
	密码:<input name="password" id="password" type="password"  value="admin"/><br>
	姓名:<input name="name" type="text" id="name" value="archerkang" /><br>
	性别:<label><input name="sex" type="radio" checked="checked" value="male" />男</label> 
<label><input name="sex" type="radio" value="female" />女</label><br>
	手机号:<input name="mobilePhone" id="mobilePhone" type="text" value="18066725237" /><br>
	email:<input type="text" name="email" id="email"  value="991941514@qq.com"/><br>
	qq:<input type="text" name="qq" id="qq" value="991941514" /><br>
	<label><input name="type" type="radio" value="1" checked="checked" />学生</label> 
<label><input name="type" type="radio" value="2" />助教</label> 
<label><input name="type" type="radio" value="3" />老师</label> <br>
</form>
<button onclick="login()">登录</button>
<button onclick="test()">test</button>
</center>
</body>
<script>

var test=function(){
	alert("do");
	 window.location.href="login.jsp";
	 alert("end");
}

var login=function(){
	var userCode =$("#userCode").val();
	var password =$("#password").val();
	var name =$("#name").val();
	var mobilePhone =$("#mobilePhone").val();
	var email =$("#email").val();
	var qq =$("#qq").val();
	var sex =$("input[name='sex']:checked").val();
	var type =$("input[name='type']:checked").val();
	 var json={
			 userCode:userCode,
			 password:password,
			 name:name,
			 mobilePhone:mobilePhone,
			 email:email,
			 qq:qq,
			 sex:sex,
			 type:type
	 }
	 
	 $.ajax({ 
         type:"POST", 
         url:"http://localhost:8080/CourseSupport/user/register", 
         dataType:"json",      
         contentType:"application/json",               
         data:JSON.stringify(json), 
         success:function(data){ 
        	 if(data.status=="succsss"){
        		 window.location.href="login.jsp";
         	  }else{
         		  alert(data.status);
         	  }
         } 
      }); 
	
}
</script>
</html>